import java.util.Arrays;

class Dog {
    private int age;
    public String name;

public void eat () {
    System.out.println(name + "chif");
}

    public Dog () {
        this(20,"haha");
        System.out.println("aaa");
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Dog (int age, String name) {
        //this();
        this.age = age;
        this.name = name;
        System.out.println("crec");
        System.out.println(age + " " +name);
    }
    public static void main(String[] args) {
         Dog dog1 = new Dog();
         dog1.eat();

    }

}
public class javatest {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(array));

    }
    public static void main99(String[] args) {
        Dog dog2 = new Dog();
       dog2.setAge(10);
        System.out.println(dog2.getAge());
    }

    public static int MaoPaopx(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] > array[j + 1]) {
                    int num = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = num;
                }
            }
        }
        return array [array.length / 2];
    }
    public static void main16(String[] args) {
        int[] array = {1,2,1,2,1,2,2,2,};
        int ret = MaoPaopx(array);
        System.out.println(ret);
    }
    public static boolean Threeoddnumbers(int[] array) {
        int j = 0;
        while (j < array.length - 2) {
            if (array[j] % 2 != 0 && array[j + 1] % 2 != 0 && array[j + 2] % 2 != 0) {
                return true;
            }
            j++;
        }
        return false;
    }
    public static void main15(String[] args) {
        int[] array = {2,4,6,8,10,1,3,5,12,14};
        boolean ret = Threeoddnumbers(array);
        System.out.println(ret);
    }
    public static int Anumberthatappearsonlyonce(int[] array) {
        int num = 0;
        for (int i = 0; i < array.length; i++) {
            num ^= array[i];
        }
        return num;
    }
    public static void main14(String[] args) {
        int[] array = {2,5,1,2,1,3,6,4,5,3,4};
        int num = Anumberthatappearsonlyonce(array);
        System.out.println(num);
    }
    public static int[] sum6 (int[] array, int num) {
        int[] arr = new int[2];
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] + array[j] == num) {
                    arr[0] = i;
                    arr[1] = j;
                   return arr;
                }
            }
        }
       return arr;
    }
    public static void main13(String[] args) {
        int[] array = {2,7,15,19,20};
        int[] ret = sum6 (array,39);
        System.out.println(Arrays.toString(ret));
    }
    public static int BinarySearch(int[] array,int ret) {
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            int num = (left + right) / 2;
            if(array[num] > ret) {
                right = num - 1;
            } else if (array[num] == ret) {
                return num;
            } else {
                left = num + 1;
            }
        }
       if(array[left] == ret) {
           return left;
       } else {
           return -1;
       }
    }
    public static void main12(String[] args) {
        int[] array = {1,3,5,7,9,11,13,15};
        int num = BinarySearch(array, 9);
        System.out.println("下标是 = " + num);
    }
    public static void Tonpten(int[] array) {
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            while(array[left] % 2 != 0) {
                left++;
            }
            while(array[right] % 2 == 0) {
                right--;
            }
            if (left < right) {
                int srt = array[left];
                array[left] = array[right];
                array[right] = srt;
                left++;
                right--;
            }
        }
    }
    public static void main11(String[] args) {
        int[] array = {1,3,5,4,2,6,8,7,9};
        Tonpten(array);
        System.out.println(Arrays.toString(array));
    }
    public static void transform(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i] * 2;
        }

    }
    public static void main10(String[] args) {
        int[] array = {1,2,3,4,5};
        transform(array);
        System.out.println(Arrays.toString(array));
    }
    public static void MaoPaopx1(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] > array[j + 1]) {
                    int num = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = num;
                }
            }
        }
    }
    public static void main9(String[] args) {
        int[] array = {9,7,5,3,1};
        MaoPaopx1(array);
        System.out.println(Arrays.toString(array));
    }
    public static String ret1(int[] array) {
        String arr = "[";
        for (int i = 0; i < array.length; i++) {
            arr += array[i];
            if(i < array.length - 1) {
                arr += ", ";
            }
        }
        arr += "]";
        return arr;
    }
    public static void main8(String[] args) {
        int[] array = {1,2,3,4,5};
        System.out.println(ret1(array));
    }
    public static void move(char x,char y) {
        System.out.println(x + "->" + y);
    }
    public static void ret(int n, char a, char b, char c) {
        if(n==1) {
            move(a, c);
        } else {
            ret(n - 1, a, c, b);
            move(a, c);
            ret(n - 1, b, a, c);
        }
    }
    public static void main7(String[] args) {
        ret(15,'A', 'B', 'C');
    }
    public static int WhoBig(int x,int y) {
        return x > y ? x : y;
    }
    public static double WhoBig(double x,double y,double z) {
        double a = x > y ? x : y;
        return a > z ? a : z;
    }
    public static void main6(String[] args) {
        System.out.println("num = " + WhoBig(9,6));
        System.out.println("ret = " + WhoBig(1.5,2.5,3.5));
    }
    public static int add(int x,int y) {
        return x + y;
    }
    public static double add(double x,double y,double z) {
        return x + y + z;
    }
    public static void main5(String[] args) {
        System.out.println("num = " + add(6,8));
        System.out.println("ret = " + add(1.5,2.5,3.5));
    }
    public static int Max3(int x, int y, int z) {
       int max = Max2(x, y);
       if(max > z) {
           return max;
       } else {
           return z;
       }
    }
    public static int Max2(int x, int y) {
        if(x > y) {
            return x;
        } else {
            return y;
        }
    }
    public static void main4(String[] args) {
        System.out.println("max = " + Max3(3,9,6));
    }
    public static void main3(String[] args) {
        int[] arry = {1,2,3,4,5,6};
        for(int i = 0; i < arry.length; i++) {
            System.out.println(arry[i]);
        }
    }
    public static int sum(int n) {
        if(n < 10) {
            return n;
        }
        return n%10 + sum(n/10);
    }
    public static void main2(String[] args) {
        System.out.println(sum(1729));
    }
    public static int add(int n) {
        if(n == 0) {
            return 0;
        }
        return n + add(n-1);
    }

    public static void main1(String[] args) {

        System.out.println(add(10));
    }
}
